<%--
  Created by IntelliJ IDEA.
  User: mr.chan
  Date: 2022/4/27
  Time: 下午11:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@page isELIgnored="false" %>
<html>
<head>
    <title>J14用户列表</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <%-- jquery库--%>
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
            integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
            crossorigin="anonymous"></script>
    <script type="text/javascript">
        function doDel(id) {
            if (confirm("确认删除吗？")) {
                location.href = "${pageContext.request.contextPath}/user/delete/" + id;
            }
        }

        function doBatchDel() {
            if (confirm("确认删除吗？")) {
                /*1.获取选中的用户的id*/
                var ids = "";//="ids=47&ids=30&ids=80" ;
                $("input:checked").each(function () {
                    ids += "ids=" + $(this).val() + "&";
                })
                /*2.去除最后一个&*/
                ids = ids.substr(0, ids.length - 1);
                alert(ids);
                /*3.发送批量删除的请求*/
                //http://localhost:8080/nd-springmvc01-base07/user/batch_del?ids=47&ids=30
                location.href = '${pageContext.request.contextPath}' + '/user/batch_del?' + ids;
            }
        }
    </script>
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-bordered table-hover table-condensed">
                <caption style="text-align: center">
                    <h1>J14人员管理系统</h1>
                </caption>

                <thead>
                <tr>
                    <th colspan="6">
                        <a href="to_add" class="glyphicon glyphicon-plus" aria-hidden="true"></a>
                        <a href="javascript:doBatchDel()" class="glyphicon glyphicon-minus" aria-hidden="true"></a>
                    </th>
                </tr>
                <tr>
                    <th><input type="checkbox" name="all"/></th>
                    <th>
                        编号
                    </th>
                    <th>
                        用户名
                    </th>
                    <th>
                        地址
                    </th>
                    <th>
                        性别
                    </th>
                    <th>
                        状态
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${userList}" var="user" varStatus="status">
                    <c:if test="${status.index%2==0}">
                        <tr class="success">
                    </c:if>
                    <c:if test="${status.index%2==1}">
                        <tr class="info">
                    </c:if>
                    <th><input type="checkbox" name="ids" value="${user.id}"/></th>
                    <td>
                            ${user.id}
                    </td>
                    <td>
                            ${user.username}
                    </td>
                    <td>
                            ${user.address}
                    </td>
                    <td>
                            ${user.sex}
                    </td>
                    <td>
                        <c:if test="${user.userStatus==1}">正常</c:if>
                        <c:if test="${user.userStatus==0}"><span style="color: red">冻结</span> </c:if>
                    </td>
                    <th style="text-align: center">
                        <a class="glyphicon glyphicon-pencil" style="margin-right: 10px;"
                           href="detail3?id=${user.id}"></a>
                        <a class="glyphicon glyphicon-trash" href="javascript:doDel(${user.id})"></a>
                    </th>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <div style="text-align: center;">
                <ul class="pagination">
                    <li>
                        <a href="#">上一页</a>
                    </li>
                    <li>
                        <a href="#">1</a>
                    </li>
                    <li>
                        <a href="#">2</a>
                    </li>
                    <li>
                        <a href="#">3</a>
                    </li>
                    <li>
                        <a href="#">4</a>
                    </li>
                    <li>
                        <a href="#">5</a>
                    </li>
                    <li>
                        <a href="#">下一页</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
</body>
</html>
